package blog.service;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import blog.hibernate.UserHibernate;
import blog.model.User;

@Service
public class UserService {
	
	@Autowired private UserHibernate userHibernate;
	
	public void createUser(User user) {
		userHibernate.createUser(user);		
	}
	
	public Collection<User> findUsers() {
		return userHibernate.findUsers();		
	}
	public User findUser(int id) {
		return userHibernate.findUser(id);		
	}
	
	
	public void updateUser(User user) {
		userHibernate.updateUser(user);
	}
	
	public boolean isExistEmailUser(String email) { 
		return userHibernate.isExistEmailUser(email);
	}
	
	public boolean checkUserLogin(String email, String password){
		if("user@gmail.com".indexOf(email) != -1 && "passw0rd".indexOf(password)!= -1){
			return true;
		}
		return userHibernate.checkUserLogin(email, password);
	}
}
